package com.example.md.mddemo.entity;

import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.util.Assert;

import java.util.List;
import java.util.Map;


/**
 * Copyright © 2017年 ziniuxiaozhu. All rights reserved.
 *
 * @Author 临江仙 hzqiuxm@163.com
 * 人的实体对象
 * @Date 2018/8/1 19:27
 */
@Document
public class Person {

    @Id
    private ObjectId id;

//    @Excel(name = "姓名")
    private String name;

//    @Excel(name ="年龄")
    private int age;

    private List<String> address;

//    @Excel(name = "信息描述",needMerge = true)
    private Map<String,String> des;

    public List<String> getAddress() {
        return address;
    }

    public void setAddress(List<String> address) {
        this.address = address;
    }

    public Map<String, String> getDes() {
        return des;
    }

    public void setDes(Map<String, String> des) {
        this.des = des;
    }

    public Person(String name, int age) {

        //上层捕获异常，对异常进行友好提示处理
        Assert.isTrue(age > 0, "The age of Person to be bought must be greater than 0!");
        this.name = name;
        this.age = age;
    }

    public ObjectId getId() {
        return id;
    }

    public String getName() {
        return name;
    }
    public int getAge() {
        return age;
    }

    public void setId(ObjectId id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public boolean checkPerson(){

        return true;
    }

    public Person() {
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", address=" + address +
                ", des=" + des +
                '}';
    }

}
